<!-- 项目管理 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">职位列表</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      v-if="jdsfsd"
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      :czFun="czFun"
      czWidth="300"
      ref="databale"
    ></dxtable>
    <div class="vertical-center mt100" v-else>
      <div>
        <div class="spinner">
          <div class="half-circle-spinner">
            <div class="circle circle-1"></div>
            <div class="circle circle-2"></div>
          </div>
        </div>
        <div class="fz12 z9 cen">加载中...</div>
      </div>
    </div>

    <n-modal v-model:show="showModal" preset="card" class="dsfsdfgeyty">
    <template #header>
    <div>已投简历</div>
    </template>
    <div>
    <ytd :zwname="zwname"></ytd>
    </div>
    <template #action>
    <div class="tr">
    <n-button @click="showModal=false"> 关闭 </n-button>
    </div>
    </template>
    </n-modal>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost,hf } from "../../util/index";
import { NButton, NImage, NTag,NSwitch } from "naive-ui";
import { h, ref, reactive, render } from "vue";
import ytd from "./ytd.vue"
const showModal = ref()
const databale = ref();
const xmlxSelect = ref([]);
const jdsfsd = ref(false);
const zwname = ref()
const initeer = () => {
  databale.value.initDataExpose();
};
const portUrl = "cbrc/zwgl/zwgl";
let dataJson = [
  {
    title: "公司",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "gsid",
    width: "",
    search: true,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return dataJson[0].options.filter((a) => a.value == row.gsid)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "类别",
    type: "select",
    options: [],
    val: [],
    key: "leibie",
    search: true,
    render: (row) => {
      let hjdsfds = []
      dataJson[1].options.map(a=>{
        row.leibie.split(",").map(b=>{
          if(a.value==b){
            hjdsfds.push(a.label)
          }
        })
      })
      return hjdsfds.join("、")
      // try {
      //   return dataJson[1].options.filter((a) => a.value == row.leibie)[0]
      //     .label;
      // } catch (e) {}
    },
  },
  {
    title: "职位名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "name",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "薪资",
    type: "select",
    options: [],
    val: [],
    key: "xinzi",
    search: true,
    render: (row) => {
      try {
        return dataJson[3].options.filter((a) => a.value == row.xinzi)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "经验",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "jy",
    width: "",
    search: true,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return dataJson[4].options.filter((a) => a.value == row.jy)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "学历",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "xueli",
    width: "",
    search: true,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return dataJson[5].options.filter((a) => a.value == row.xueli)[0].label;
      } catch (e) {}
    },
  },
  {
    title: "招聘人数",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "zprs",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      try {
        return row.zprs + "人";
      } catch (e) {}
    },
  },
  {
    title: "地址",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "dizhi",
    width: "",
    search: false,
    istable: true,
    required: false,
    render: (row) => {
      try{
        if(row.fldy.split(",").length<=1){
          row.fldy =[row.fldy]
        }
        
      }catch(e){

      }
      try{
        if(row.leixin.split(",").length<=1){
          row.leixin =[row.leixin]
        }
        
      }catch(e){

      }

      try{
        if(row.leibie.split(",").length<=1){
          row.leibie =[row.leibie]
        }
        
      }catch(e){

      }
      
      
      try {
        return row.sheng + "-" + row.shi;
      } catch (e) {}
    },
  },
  {
    title: "推荐",
    key:"tuijian",
    render: (row) => {
       return h(NSwitch,{'default-value':row.tuijian==2?true:false, "on-update:value": async(e) => {
        let jdfds = 2
        if(row.tuijian==2){
            jdfds=1
        }
            await dxpost(portUrl,{id:row.id,tuijian:jdfds},"put")
       }})
    }
  },
  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "chuanbo"; //数据库
      row.databaseName = "zwgl"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "cbrczwgldel", //删除
  EditPermissionIdentifier: "cbrczwglbj", // 编辑
  NewPermissionIdentifier: "cbrczwglxz", // 新建
  ViewPermissionID: "cbrczwglck", // 查看
};


let formJson = reactive([
  {
    title: "公司",
    type: "select",
    options: [],
    val: [],
    span: 12,
    key: "gsid",
  },
  {
    title: "类别",
    type: "select",
    options: [],
    val: [],
    span: 12,
    multiple:true,
    key: "leibie",
  },
  {
    title: "职位名称",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "name",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "薪资",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "xinzi",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "经验",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "jy",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "学历",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 12,
    key: "xueli",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "招聘人数",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "zprs",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "招聘类型",
    type: "select",
    options: [],
    val: [],
    icon: "dx-shurukuang",
    span: 24,
    key: "leixin",
    width: "",
    search: false,
    multiple: true,
    required: false,
  },
  {
    title: "地址",
    type: "shengshi",
    val: "",
    icon: "dx-shurukuang",
    span: 12,
    key: "dizhi",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "职位描述",
    type: "fwb",
    val: "",
    icon: "dx-m-fuwenben",
    span: 24,
    key: "zhiweims",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "任职要求",
    type: "fwb",
    val: "",
    icon: "dx-m-fuwenben",
    span: 24,
    key: "rzyq",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "福利待遇",
    type: "Tags",
    icon: "dx-tag",
    val: [],
    span: 24,
    key: "fldy",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {
            zwname.value = row.name
            showModal.value = true
          },
        },
        "查看投递简历"
      ),
    ];
  },
};

// 获取字典内容
const xtgxxmfl = async () => {
  const sdfdsf1 = await dxget("dxgjAdmin/getzd", { name: "cbrcxinzi" });
  const sdfdsf2 = await dxget("dxgjAdmin/getzd", { name: "cbrcjinyan" });
  const sdfdsf3 = await dxget("dxgjAdmin/getzd", { name: "cbrcxueli" });
  const sdfdsf4 = await dxget("cbrc/api/getgongsi");
  const sdfdsf5 = await dxget("dxgjAdmin/getzd", { name: "cbrczplb" });
  const sdfdsf6 = await dxget("dxgjAdmin/getzd", { name: "cbrccplx" });
  dataJson[0].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf4.data,
  ];
  formJson[0].options = sdfdsf4.data;

  dataJson[1].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf5.data,
  ];
  formJson[1].options = sdfdsf5.data;

  dataJson[3].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf1.data,
  ];
  formJson[3].options = sdfdsf1.data;

  dataJson[4].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf2.data,
  ];
  formJson[4].options = sdfdsf2.data;

  dataJson[5].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf3.data,
  ];
  formJson[5].options = sdfdsf3.data;

  dataJson[7].options = [
    {
      label: "全部",
      value: "",
    },
    ...sdfdsf6.data,
  ];
  formJson[7].options = sdfdsf6.data;

  xmlxSelect.value = sdfdsf1.data;
  jdsfsd.value = true
};
xtgxxmfl();
</script>
<style scoped></style>
